import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useUserStore = defineStore(
  'user',
  () => {
    const token = ref('')
    const setToken = (val) => {
      token.value = val
    }
    const clearToken = () => {
      token.value = ''
    }
    const getToken = () => {
      return token.value
    }
    const userInfo = ref({})
    const setUserInfo = (val) => {
      userInfo.value = val
    }
    return { token, setToken, clearToken, getToken, userInfo, setUserInfo }
  },
  {
    persist: true
  }
)
